package com.heima.behavior.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.heima.behavior.dto.LikeDto;
import com.heima.behavior.dto.UnLikesBehaviorDto;
import com.heima.behavior.entity.ApUnlikesBehavior;
import com.heima.behavior.service.IApUnlikesBehaviorService;
import com.heima.common.dto.ResponseResult;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * APP不喜欢行为表 前端控制器
 * </p>
 *
 * @author mcm
 * @since 2022-01-18
 */
@RestController
@RequestMapping("/api/v1/unlikes_behavior")
@Api(tags = "APP不喜欢行为表接口")
public class ApUnlikesBehaviorController{

    @Autowired
    private IApUnlikesBehaviorService apUnlikesBehaviorService;

    /**
     * 是否不感兴趣
     * @return
     */
    @PostMapping
    public ResponseResult saveUnLikes(@RequestBody UnLikesBehaviorDto dto){
        return apUnlikesBehaviorService.saveUnLikes(dto);
    }

    @PostMapping("/getUnLike")
    public ApUnlikesBehavior getUnLike(@RequestBody LikeDto dto){
        LambdaQueryWrapper<ApUnlikesBehavior> wrapper = new LambdaQueryWrapper<>();

        wrapper.eq(ApUnlikesBehavior::getArticleId,dto.getArticleId());
        return apUnlikesBehaviorService.getOne(wrapper);
    }

}
